package 刷题.leedcode2;
//使用虚拟头结点从头插入反转链表
public class Solution_3 {
    public ListNode reverseList(ListNode head){
        ListNode dummy = new ListNode(0,null);//dummy哑结点
        ListNode cur = head;
        ListNode tmp;
        while(cur != null){
            tmp = cur.next;//临时保存cur.next
            cur.next = dummy.next;
            dummy.next = cur;
            cur = tmp;
        }
    }
}
